<template>
  <div>
    <p>{{ msg }}</p>
    <input type="button" value="浪起来" @click="move" />
    <input type="button" value="停止" @click="pause" />
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      msg: "我拿Buff,谢谢~",
      time: "",
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    move() {
      if (this.time != "") {
        clearInterval(this.time);
      }
      this.time = setInterval(() => {
        const arr = this.msg.split("");
        arr.push(this.msg.split("")[0]);
        arr.splice(0, 1);
        this.msg = arr.join("");
      }, 1000);
    },
    pause() {
      clearInterval(this.time);
    },
  },
};
</script>

<style scoped lang="less"></style>
